﻿using Dapper;
using System;
using BCEntity.Trading.SaleContract;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using BCCommon.TradingEnums;

namespace BCData.Trading.SaleContract
{
    /// <summary>
    /// 销售合同
    /// </summary>
    public interface ISaleContractData
    {
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="saleContractId">销售合同Id</param>
        Task<bool> Exists(long saleContractId);
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="saleContractNo">销售合同编号</param>
        Task<bool> Exists(string saleContractNo);
        /// <summary>
        /// 增加销售合同
        /// </summary>
        /// <param name="entity">销售合同信息</param>
        Task<SaleContractEntity> Add(SaleContractEntity entity);
        /// <summary>
        /// 更新销售合同
        /// </summary>
        /// <param name="entity">销售合同信息</param>
        Task<SaleContractEntity> Update(SaleContractEntity entity);
        /// <summary>
        /// 删除销售合同
        /// </summary>
        /// <param name="saleContractId">销售合同Id</param>
        Task<bool> Delete(long saleContractId);
        /// <summary>
        /// 获取销售合同
        /// </summary>
        /// <param name="saleContractId">销售合同Id</param>
        Task<SaleContractEntity> GetEntity(long saleContractId);
        /// <summary>
        /// 获取销售合同列表
        /// </summary>
        /// <param name="userId">用户Id</param>
        Task<IEnumerable<SaleContractEntity>> GetList(long userId);
        /// <summary>
        /// 获取销售合同分页列表
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="saleContractStatus">销售合同状态</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        Task<(IEnumerable<SaleContractEntity>, int)> Query(long? userId, SaleContractStatusType? saleContractStatus, DateTime? start, DateTime? end, string sortName, bool? ascending, int pageIndex, int pageSize);
        #endregion  成员方法

        #region 修改支付方式
        /// <summary>
        /// 修改支付方式
        /// </summary>
        /// <param name="entity">销售合同信息</param>
        /// <returns></returns>
        Task<SaleContractEntity> UpdatePaymentMode(SaleContractEntity entity);
        #endregion

        #region 修改支付信息
        /// <summary>
        /// 修改销售合同支付信息（定金）
        /// </summary>
        /// <param name="entity">销售合同信息</param>
        /// <returns></returns>
        Task<SaleContractEntity> UpdatePaymentInfoToDeposit(SaleContractEntity entity);
        /// <summary>
        /// 修改销售合同支付信息（尾款）
        /// </summary>
        /// <param name="entity">销售合同信息</param>
        /// <returns></returns>
        Task<SaleContractEntity> UpdatePaymentInfoToLast(SaleContractEntity entity);
        /// <summary>
        /// 修改支付信息
        /// </summary>
        /// <param name="entity">销售合同信息</param>
        /// <returns></returns>
        Task<SaleContractEntity> UpdatePaymentInfo(SaleContractEntity entity);
        #endregion
    }


}